package Test_0814.ioperations;

import Test_0814.book.Book;
import Test_0814.book.BookShelf;
import org.w3c.dom.ls.LSOutput;

import java.util.Scanner;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-08-15
 * Time: 9:36
 */
public class ReturnOperation implements IoPeration{
    public void work(BookShelf bookshelf){
        System.out.println("归还图书");
        System.out.println("请输入你要归还的图书");
        Scanner scanner=new Scanner(System.in);
        String returnName=scanner.nextLine();
        int ret=bookshelf.getUseSize();
        for (int i = 0; i < ret; i++) {
            Book book=bookshelf.getBook(i);
            if(book.getBookName().equals(returnName)){
                book.setBorrow(false);
                System.out.println("归还成功");
                return;
            }
            System.out.println("没有你要归还的图书");

        }
    }


}
